package com.xbongbong.pro.dataset.node;

import com.google.common.collect.Maps;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.dataset.exception.JsonParseException;
import com.xbongbong.pro.statistic.pojo.dto.SqlParseDTO;

import java.util.Map;

/**
 * @author  gzt
 * @Description node处理接口
 * @Date 14:41 2022/5/26
 **/
public interface NodeStrategy {
    /**
     * @author  gzt
     * @Description 线程独立保存各节点生成的sql语句
     * @Date 19:19 2022/10/11
     **/
    ThreadLocal<Map<String, String>> SQL_NODES_THREAD_LOCAL = new ThreadLocal<Map<String, String>>(){
        @Override
        protected Map<String, String> initialValue(){
            return Maps.newHashMap();
        }
    };

    /**
     * @author  gzt
     * @Description 线程独立保存
     * @Date 19:19 2022/10/11
     **/
    ThreadLocal<Map<String, String>> NODE_TABLE_NAME_THREAD_LOCAL = new ThreadLocal<Map<String, String>>(){
        @Override
        protected Map<String, String> initialValue(){
            return Maps.newHashMap();
        }
    };

    ThreadLocal<Map<String, String>> NODE_FORM_ID_THREAD_LOCAL = new ThreadLocal<Map<String, String>>(){
        @Override
        protected Map<String, String> initialValue(){
            return Maps.newHashMap();
        }
    };
    /**
     * @author  gzt
     * @Description 节点类型缓存
     * @Date 15:56 2022/11/2
     **/

    ThreadLocal<Map<String, String>> NODE_TYPE_THREAD_LOCAL = new ThreadLocal<Map<String, String>>(){
        @Override
        protected Map<String, String> initialValue(){
            return Maps.newHashMap();
        }
    };

    /**
     * @author  gzt
     * @Description 解析画布节点并生成sql
     * @Date 19:53 2022/10/11
     * @param sqlParseDTO
     * @throws
     **/
    void parseNodeToSql(SqlParseDTO sqlParseDTO) throws JsonParseException, XbbException;

    /**
     * @author  gzt
     * @Description 获取NodeType
     * @Date 19:24 2022/10/11
     * @return java.lang.String
     **/

    String getNodeType();
    /**
     * @author  gzt
     * @Description 获取解析后的SQL语句
     * @Date 19:24 2022/10/11
     * @param nodeId
     * @return java.lang.String
     **/

    String getParseSql(String nodeId);
}
